package com.fanghuaiming.fescar.account.controller;

import com.fanghuaiming.fescar.account.dao.model.Account;
import com.fanghuaiming.fescar.account.service.AccountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/****
 * @description: 账户服务接口
 * @version:1.0.0
 * @author fanghuaiming
 * @data Created in 2020/11/27 下午2:00
 *
 */
@Slf4j
@RestController("account")
@RequestMapping("/account")
public class AccountController {

    /**
     * 账户服务
     */
    @Autowired
    private AccountService accountService;

    /**
     * @Description: 扣减账户
     *
     * @param:
     * @return:
     * @auther: fanghuaiming
     * @date: 2020/11/27 下午2:25
     * @version:1.0.0
     */
    @PostMapping(value = "/reduceAccount")
    public String reduceAccount(@RequestBody Account account) {
        try {
            log.info("=================开始请求-账户微服务-reduceAccount扣减账户Controller接口=================");
            accountService.reduceAccount(account);
        } catch (Exception e) {
            e.printStackTrace();
            return "接口异常,事务回滚";
        }
        log.info("=================请求-账户微服务-reduceAccount扣减账户Controller接口成功=================");
        return "请求成功";
    }

}
